﻿using System;
using System.Text;

namespace GPS.GPSLanguage
{
    class AltitudeToken
    {
        internal static void ParseLanguage(GPSData gpsData, System.Collections.Queue q)
        {
            String altValToken = (string)q.Dequeue();

            String altUnitTypeToken = (string)q.Dequeue();

            double val;
            UnitType unitType;
            Toolkit.ParseValAndUnit(out val, out unitType, altValToken, altUnitTypeToken);

            gpsData.SetAltitudeAndUnitType(val, unitType);

            switch (gpsData.MessageType)
            {
                case MessageType.GPGGA:
                    HeightOfGeoIdToken.ParseLanguage(gpsData, q);
                    break;
                default:
                    throw new InvalidLanguageException("How did you get here?");
            }
        }
    }
}
